﻿using UnityEngine;
using System.Collections;

public class LogoFade : MonoBehaviour {

    public string sceneName;
    public float fadeAmount;
    public float stayTime;

    private float timer;
    private FadeIn fade;

    void Awake()
    {
        fade = (FadeIn)gameObject.AddComponent("FadeIn");
        gameObject.AddComponent("ChangeScene");
        fade.createFade(fadeAmount);
    }

    void Update()
    {

        if (fade == null)
        {
            timer += Time.deltaTime;
        }

        if (timer > stayTime)
        {
            if (gameObject.GetComponent<ChangeScene>().existFade())
            {
                gameObject.GetComponent<ChangeScene>().createFade(sceneName, fadeAmount);
            }
        }

    }
}
